package com.xian.memory;

public class ArrayDemo2 {
    public static void main(String[] args) {
        //目标：两个数组变量指向同一个数组对象

        //方法区(放class文件)-->栈内存(main方法)-->堆内存(new出来的对象)
        int [] arr1 = {11,22,33};

        //两个就同时指向堆内存里面的值
        int [] arr2 = arr1;  //把地址赋给2，，，，，数组的赋值实际就是传的地址

        System.out.println(arr1);  //[I@1b6d3586
        System.out.println(arr2);  //[I@1b6d3586

        //同时指向同一个数组，只要这个数组值改了，，，不管哪个访问的值都改了
        arr2[1] = 99;

        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);
        //11
        //99
        //33
        System.out.println("-----------------");
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);
        //11
        //99
        //33




    }
}
